import pymysql
import requests

db = pymysql.connect(host='localhost', user='root', passwd='123456', db='test', port = 3306)

def get_task_duration(task_id):
    cusor = db.cursor()
    sql = 'select duration from dataset where task_id = "{}"'.format(task_id)
    cusor.execute(sql)
    row = cusor.fetchone()
    if row:
        duration = row[0]
    else:
        duration = 0
    return duration

duration = get_task_duration("5d11acfacf0102385c428d1c")
print(duration)